<?php
/**
 * Created by IDEA.
 * User: dinesh
 * Date: Jul 29, 2013
 * Time: 1:37:27 PM
 * To change this template use File | Settings | File Templates.
 */

class Distribution {
    public function getMonth($name = "month", $selected = null) {
        // $mm = '<select name="'.$name.'" id="'.$name.'">';

        $months = array(
            1 => 'January',
            2 => 'February',
            3 => 'March',
            4 => 'April',
            5 => 'May',
            6 => 'June',
            7 => 'July',
            8 => 'August',
            9 => 'September',
            10 => 'October',
            11 => 'November',
            12 => 'December');
        /*** the current month ***/
        $selected = is_null($selected) ? date('n', time()) : $selected;

        for ($i = 1; $i <= 12; $i++)
        {
            $mm .= '<option value="' . $i . '"';
            if ($i == $selected) {
                $mm .= ' selected';
            }
            /*** get the month ***/
            $mm .= '>' . $months[$i] . '</option>';
        }
        //$mm .= '</select>';
        return $mm;
    }

    public function getYear($name = "year", $useDate = 0) {
        //  $yy = '<select name="'.$name.'" id="'.$name.'">';
        $startYear = DATE("Y");
        FOR ($currentYear = $startYear - 5; $currentYear <= $startYear + 5; $currentYear++)
        {
            $yy .= "<OPTION VALUE=\"$currentYear\"";
            IF ($startYear == $currentYear) {
                $yy .= " SELECTED";
            }
            $yy .= ">$currentYear\n";
        }
        // $yy .= "</SELECT>";
        return $yy;
    }

}
